package com.zenithsun.common.review.service.impl;

import java.util.Date;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.syzg.common.service.impl.BaseServiceImpl;
import com.zenithsun.common.review.dao.ReviewDAO;
import com.zenithsun.common.review.model.Review;
import com.zenithsun.common.review.model.ReviewState;
import com.zenithsun.common.review.service.ReviewService;

/**
 * 审核业务实现
 * @author wanglei@enersun.com.cn
 * @createTime 2016-06-17 11:12:49
 */
@Service("reviewService")
public class ReviewServiceImpl extends BaseServiceImpl<Review> implements ReviewService {
    
    private ReviewDAO reviewDAO = null;

    @Resource
	public void setreviewDAO(ReviewDAO reviewDAO) {
		this.setDAO(reviewDAO);
		this.reviewDAO = reviewDAO;
	}

	@Override
	public Review createReview(String busId, String busMark) throws Exception {
		Review review=new Review();
		review.setBusId(busId);
		review.setBusMark(busMark);
		review.setCreateTime(new Date());
		review.setState(ReviewState.SaveNotReview.toShort());
		review.setMark(Short.valueOf("0"));
		reviewDAO.create(review);
		return review;
	}

	@Override
	public void doReview(Review review) throws Exception {
		reviewDAO.update(review);
	}

	@Override
	public boolean updateReview(Review review) throws Exception {
		return reviewDAO.updateNotBlank(review);
	}

	@Override
	public Review getReview(String busId, String busMark) throws Exception {
		return reviewDAO.getReviewByBus(busId, busMark);
	}
	
	@Override
	public Integer queryPicReview() throws Exception{
		return reviewDAO.queryPicReview();
	};
	
	@Override
	public Integer queryNewsReview() throws Exception{
		return reviewDAO.queryNewsReview();
	};
}